package com.s10.ecloud.web.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "DEVICEGROUP", catalog = "ECLOUD")
public class DeviceGroup implements java.io.Serializable {
	private int id;
	private String name;

	private IndividualUser user;

	/**
	 * @return the id
	 */
	// Property accessors
	// 这里用了新的id生成策略 uuid.string(注意 如果使用uuid.string 则会出错 hibernate3已经不支持这种生成方式)
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	@Column(name = "name", length = 32)
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	// 这里指自身与别的表做外键 所以是ManyToOne
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	// 设置自身哪个属性与别的表的主键做外键
	@JoinColumn(name = "userid")
	public IndividualUser getUser() {
		return this.user;
	}

	public void setUser(IndividualUser user) {
		this.user = user;
	}

}
